using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
using QuanLyThuVien1.DTO;
using QuanLyThuVien1.DAO;

namespace QuanLyThuVien1.BUS
{
   public class Sach_Bus
    {
       public string ChuanHoa(string m_sChuoi)
       {
           if (m_sChuoi == "")
               return m_sChuoi;
           for (int i = 0; i < m_sChuoi.Length - 1; )
           {
               if (m_sChuoi[i] == 32 && m_sChuoi[i + 1] == 32)
               {
                   m_sChuoi = m_sChuoi.Substring(0, i + 1) + m_sChuoi.Substring(i + 2, m_sChuoi.Length - i - 2);
               }
               else
                   i++;
           }
           if (m_sChuoi[0] == 32)
               m_sChuoi = m_sChuoi.Substring(1, m_sChuoi.Length - 1);
           if (m_sChuoi[m_sChuoi.Length - 1] == 32)
               m_sChuoi = m_sChuoi.Substring(0, m_sChuoi.Length - 1);
           return m_sChuoi;
       }
       public DataTable timSach(string m_TenSach, string m_TheLoai, string m_Tacgia)
       {
           m_TenSach = ChuanHoa(m_TenSach);
           m_Tacgia = ChuanHoa(m_Tacgia);
           SACH_DAO danhSachOfSach = new SACH_DAO();
           DataTable ketQua = danhSachOfSach.TimSach(m_TenSach, m_TheLoai, m_Tacgia);
           return ketQua;
       }
       public void themSachOfBus(SACH s)
       {
           SACH_DAO themSach = new SACH_DAO();
           s.TENSACH = ChuanHoa(s.TENSACH);
           s.TENTACGIA = ChuanHoa(s.TENTACGIA);
           themSach.themSach(s);

       }
       public int soSachTheoMa(string maSach)
       {
           SACH_DAO sach = new SACH_DAO();
           return sach.soCuonSach(maSach);
       }
       public DataTable TimSachTheoMaSach(string tenSach)
       {
           SACH_DAO s = new SACH_DAO();
           return s.TimSachTheoMaSach(tenSach);
       }
       public DataTable TimSachTheoLoaiSach_Bus(string loaiSach)
       {
           SACH_DAO s = new SACH_DAO();
           return s.TimSachTheoLoaiSach(loaiSach);
       }
       public DataTable TimSachTheoTacGia_Bus(string tacGia)
       {
           SACH_DAO s = new SACH_DAO();
           return s.TimSachTheoTacGia(tacGia);
       }
       public DataTable TimSachTheoDauSach_Bus(string dauSach)
       {
           SACH_DAO s = new SACH_DAO();
           return s.TimSachTheoDauSach(dauSach);
       }
       public bool KiemTraSach(string maSach)
       {
           SACH_DAO s = new SACH_DAO();
           return s.KiemTraSach(maSach);
       }
       public void TangThemSoCuonSach(string maSach, int soCuon)
       {
           SACH_DAO s = new SACH_DAO();
           s.TangThemSoSach(maSach, soCuon);
       }
       public void GiamSoSach(string maSach)
       {
           SACH_DAO s = new SACH_DAO();
           s.GiamSoSach(maSach);
       }
       public DataTable LayThongTinThanhLySach()
       {
           SACH_DAO s = new SACH_DAO();
           return s.LayThongTinThanhLySach();
       }
       public void GiamSachSauKhiThanhly_Bus(string maSach, int soCuon)
       {
           SACH_DAO s = new SACH_DAO();
           s.GiamSachSauKhiThanhLy(maSach,soCuon);
       }

       public string LayGiaTriSach_Bus(string maSach)
       {
           SACH_DAO s = new SACH_DAO();
           return s.LayGiaTriCuaSach(maSach);
       }

    }
}
